﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Empoly.aspx.cs" Inherits="WebApplication01.Empoly" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>人员管理</title>
    <link href="Content/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="Content/bootstrapTable/bootstrap-table.css" rel="stylesheet" />
    <script src="Scripts/jquery-1.10.2.js"></script>
    <script src="Content/bootstrapTable/bootstrap-table.js"></script>
    <script src="Content/bootstrapTable/bootstrap-table-zh-CN.js"></script>
   <script>
       $(function () {
           //bindDept();
           //bindRole();
           bindList();
           getData();
           $("#btnQuery").click(function () {
               //重新加载表格
               Search();
           })
       })
       function Search() {
           $("#tblData").bootstrapTable("refresh");
       }
       //function bindDept() {
       //    $.ajax({
       //        type: "get",
       //        url: "AssetHandel/DeHandler.ashx?sType=select",
       //        data: { dapt:$("#selDept").val()},
       //        dataType: "json",
       //        success: function (result) {
       //            var strHtml ='<option value="0">全部</option>';
       //            for (var i = 0; i < result.length; i++) {
       //                strHtml += '<option value="' + result[i]["DeptID"] + '">' + result[i]["DeptName"]+ '</option>';
       //            }
       //            $("#selDept").html(strHtml);
       //        } 
       //    })
       //}
       //function bindRole() {
       //    $.ajax({
       //        type: "get",
       //        url: "AssetHandel/RoleHandler.ashx?sType=select",
       //        data: { role: $("#selRole").val() },
       //        dataType: "json",
       //        success: function (result) {
       //            var strHtml = '<option value="0">全部</option>';
       //            for (var i = 0; i < result.length; i++) {
       //                strHtml += '<option value="' + result[i]["RoleID"] + '">' + result[i]["RoleName"] + '</option>';
       //            }
       //            $("#selRole").html(strHtml);
       //        }
       //    })
       //}
       function bindList() {
           $.ajax({
               type: "get",
               url: "AssetHandel/EmpolyHandler.ashx?sType=select",
               data: {
                   deptlist: $("#selDept").val(),
                   rolelist: $("#selRole").val(),},
               dataType: "json",
               success: function (result, resultt) {
                   var strHtml1 = '<option value="0">全部</option>';
                   for (var i = 0; i < result.length; i++) {
                       strHtml1 += '<option value="' + result[i]["DeptID"] + '">' + result[i]["DeptName"] + '</option>';
                   }

                   $("#selDept").html(strHtml1);
                   var strHtml2 = '<option value="0">全部</option>';
                   for (var i = 0; i < resultt.length; i++) {
                       strHtml2 += '<option value="' + resultt[i]["RoleID"] + '">' + resultt[i]["RoleName"] + '</option>';
                   }
                   $("#selRole").html(strHtml2);
               }
           })
       }
       function getData() {
           console.log($("#selDept").val());
           console.log($('input:radio[name="rdoSex"]:checked').val());
           //查全部
           //var strdept = 0;
           //var strrole = 0;
           //if ($("#selDept").val() != undefined) {
           //    strdept = $("#selDept").val();
           //} else if ($("#selRole").val != undefined) {
           //    strrole = $("#selRole").val;
           //}

           $("#tblData").bootstrapTable({
               url: "AssetHandel/EmpolyHandler.ashx?sType=list",
               pagination: true,
               sidePagination: "server",
               striped: true,
               pageNumber: 1,
               pageSize: 10,
               pageList: [5, 10, 15, 20, 25],
               queryParams: function (params) {//自定义传参
                   var temp = {
                       empname: $("#EmpName").val(),
                       //deptlist: strdept,
                       //rolelist: strrole,
                       //rdo: $('input:radio[name="rdoSex"]:checked').val(),
                       limit: params.limit,
                       offset: params.offset
                   };
                   return temp;
               },
               columns: [
                   {
                       checkbox: true
                   },
                   { field: 'EmpolyID', title: '员工ID', width: 10 },
                   { field: 'EmpolyNum', title: '员工编号', width: 80 },
                   { field: 'EmpolyName', title: '姓名', width: 10 },
                   { field: 'EmpolySex', title: '性别', width: 80 },
                   { field: 'EmpolyIdCard', title: '身份证号', width: 10 },
                   { field: 'DeptName', title: '部门名称', width: 80 },
                   {
                       field: 'EmpolyLevel', title: '级别', width: 10, formatter: function (value, row, index) {
                           if (value == "1") {
                               return "普通员工";
                           } else if (value == "2") {
                               return "部门主管";
                           } else {
                               return "校区负责人";
                           }
                       }
                   },
                   { field: 'RoleName', title: '角色名称', width: 80 },
                   { field: 'InductionDate', title: '入职时间', width: 10 },
                   { field: 'DepartureDate', title: '离职时间', width: 80 },
                   { field: 'EmpolyReMark', title: '备注', width: 80 },
                   {
                       field: '', title: '操作', width: 40, formatter: function (value, row, index) {
                           return '<button type="button" class="btn btn-warning btn-sm" onclick="Exit(' + index + ')">编辑</button>&nbsp;&nbsp;<button type="button" class="btn btn-danger btn-sm" onclick="Delete(' + row.EmpolyID + ')">删除</button>';
                       }
                   }
               ]
           })


       }
   </script>
</head>
<body>
    <div class="form-inline">
        <div class="form-group">
            <label class="col-sm control-label" for="name">姓名：</label>
            <input type="text" class="form-control" id="EmpName" placeholder="" />
            <div class="form-group">
                <label class="col-sm control-label" for="name">部门：</label>
                <select name="warehouse_name" class="form-control" id="selDept">
                    <option value="0">全部</option>
                </select>
            </div>
            <div class="form-group">
                <label class="col-sm control-label" for="name">角色：</label>
                <select name="warehouse_name" class="form-control" id="selRole">
                    <option value="0">全部</option>
                </select>
            </div>
            <label class="col-sm control-label" for="name">性别：</label>
            <input type="radio"  id="rdo1" value="男" name="rdoSex"/>男
            <input type="radio"  id="rdo2" value="女" name="rdoSex"/>女
            <input type="radio"  id="rdo3" value="全部" checked="checked" name="rdoSex"/>全部
            <button type="button" id="btnQuery" class="btn btn-primary">查询</button>
            <button type="button" id="btnAdd" class="btn btn-primary">添加</button>
            <button type="button" id="btnExcel" class="btn btn-primary">导入数据</button>
        </div>
    </div>
    <table id="tblData"></table>
</body>
</html>
